package com.qfedu.microuser;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @Classname App
 * @Description TODO
 * @Date 2025-10-09 9:19
 * @Created by 老任与码
 */
public class App3 {
    public static void main(String[] args) {
        // key 奖品id, value 中奖概率*100
        Map<Integer, Integer> map = new HashMap<>();
        map.put(1, 1);
        map.put(2, 10);
        map.put(3, 70);
        map.put(4, 10);
        map.put(5, 9);

        Integer[] testArr = new Integer[128];
        int num = 0;
        // 根据奖品数进行循环
        for (Integer key : map.keySet()) {
            int count = map.get(key);
            // 根据中奖概率指定循环次数
            for (int i = num; i < 100; i++) {
                if (i == count + num) {
                    num += count;
                    break;
                }
                int hashCode = i * 0x61c88647 + 0x61c88647;
                int index = hashCode & (128 - 1);
                System.out.println(index);
                if (testArr[index] != null) {
                    System.out.println("发生碰撞索引：" + index);
                } else {
                    testArr[index] = key;
                }

            }
        }

        System.out.println(Arrays.asList(testArr));

    }
}
